﻿using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Locator.LcboServices.LcboStoresService.Services;
using LcboServices.Common.Tests;
using Locator.LcboServices.BusinessEntities;

namespace LcboStoresService.Tests
{
    [TestFixture]
    public class Tests
    {
        [Test]
        public void GetStore568DetailsLocalFile()
        {
            using (LcboStoresServiceAgent agent = new LcboStoresServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                LcboStoreInformation store = agent.GetLocationDetails(568);
                Assert.AreEqual(568, store.StoreNumber);
                Assert.AreEqual("595 Bay Street", store.AddressLine);
                Assert.AreEqual("Toronto", store.City);
                Assert.AreEqual("(416) 979-9978", store.TelephoneNumber);
                Assert.AreEqual(43.6563M, store.Latitude.Value);
                Assert.AreEqual(-79.3813M, store.Longitude.Value);
                Assert.AreEqual("595 Bay Street Toronto ON", store.CivicAddress);
            }
        }

        [Test]
        public void GetStore7DetailsLocalFile()
        {
            using (LcboStoresServiceAgent agent = new LcboStoresServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                LcboStoreInformation store = agent.GetLocationDetails(7);
                Assert.AreEqual(7, store.StoreNumber);
                Assert.AreEqual("2087 Yonge Street", store.AddressLine);
                Assert.AreEqual("Toronto", store.City);
                Assert.AreEqual("(416) 482-1800", store.TelephoneNumber);
                Assert.AreEqual(43.702663M, store.Latitude.Value);
                Assert.AreEqual(-79.39727M, store.Longitude.Value);
                Assert.AreEqual("2087 Yonge Street Toronto ON", store.CivicAddress);
            }
        }

        [Test]
        public void GetStore2DetailsLocalFile()
        {
            using (LcboStoresServiceAgent agent = new LcboStoresServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                LcboStoreInformation store = agent.GetLocationDetails(2);
                Assert.AreEqual(2, store.StoreNumber);
                Assert.AreEqual("396 St. Clair Ave. West", store.AddressLine);
                Assert.AreEqual("Toronto", store.City);
                Assert.AreEqual("(416) 653-0220", store.TelephoneNumber);
                Assert.AreEqual(43.6842M, store.Latitude.Value);
                Assert.AreEqual(-79.4158M, store.Longitude.Value);
                Assert.AreEqual("396 St. Clair Ave. West Toronto ON", store.CivicAddress);
            }
        }

        [Test]
        public void GetStore496DetailsLocalFile()
        {
            using (LcboStoresServiceAgent agent = new LcboStoresServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                LcboStoreInformation store = agent.GetLocationDetails(496);
                Assert.AreEqual(496, store.StoreNumber);
                Assert.AreEqual("6179 Perth St", store.AddressLine);
                Assert.AreEqual("Richmond", store.City);
                Assert.AreEqual("(613) 838-5123", store.TelephoneNumber);
                Assert.AreEqual(45.194435M, store.Latitude.Value);
                Assert.AreEqual(-75.83887M, store.Longitude.Value);
                Assert.AreEqual("6179 Perth St Richmond ON", store.CivicAddress);
            }
        }

        [Test]
        public void GetAllStores()
        {
            using (LcboStoresServiceAgent agent = new LcboStoresServiceAgent(new LocalFilePageRetrieverFactory()))
            {
                var stores = agent.GetAllStores();
                Assert.AreEqual(612, stores.Count);
                Assert.AreEqual("595 Bay Street", stores[0].AddressLine);
            }
        }
    }
}
